package com.itheima.service.impl;


import com.itheima.annotation.OpLog;
import com.itheima.domain.pojo.Dept;
import com.itheima.mapper.DeptMapper;
import com.itheima.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.time.LocalDateTime;
import java.util.List;
@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptMapper deptMapper;
    @Override
    public List<Dept> findAll() {
        return deptMapper.selectAll();
    }
    @OpLog
    @Override
    public void deleteById(Integer id) {
        deptMapper.deleteById(id);
    }

    @OpLog
    @Override
    public void insertDept(@RequestBody Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());

        deptMapper.insertDept(dept);
    }

    @Override
    public Dept getById(Integer id) {
        return deptMapper.getById(id);
    }
    @OpLog
    @Override
    public void upadteDept(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.upadteDept(dept);
    }


}
